$(function(){
	//初始化日期控件
  	$('#bt, #et').datetimepicker({
  		language: 'zh-CN',
	    format: 'yyyy-mm-dd hh:00',
	    autoclose: true,
	    minuteStep: 1,
	    minView: "day"
	});
});

//加载奖券变化列表数据
function loadDatas(s){
	
	if(s=="search"){
		$("#page").val("");
	}

	//页码
	var page = $("#page").val();
	//一页显示的条数
	var pageSize = 40;
	//用户推广号
	var gameId = $("#gameId").val();
	//开始时间
	var begin = $("#begin_time").val();
	//结束时间
	var end = $("#end_time").val();
	
	$.ajax({
		type: "post",
		data: {"page":page, "pageSize":pageSize, "begin":begin, "end":end, "gameId":gameId},
		url: "../../../php/player/playerInfo/loadPlayerLotteryChangeData.php",
		beforeSend: function(){
			$("#load").css("display","block");
		},
		success: function(msg){
			$("#load").css("display","none");
			
//			console.log(msg);
			
			//用户信息
			var userInfo = msg.userInfo;
			$("#tgh").html(userInfo[0].gameId==""?"-":"<a href='./playerDetailsInfo.php?gameId="+userInfo[0].gameId+"' title='查看玩家详情'>"+userInfo[0].gameId+"</a>");
			$("#nickName").html(userInfo[0].nickName==""?"-":"<a href='./playerDetailsInfo.php?gameId="+userInfo[0].gameId+"' title='查看玩家详情'>"+userInfo[0].nickName+"</a>");
			$("#userid").html(userInfo[0].userId==""?"-":userInfo[0].userId);
			
			//金币总变动
			var jqZbd = msg.pageInfo;
			$("#zbd").html(jqZbd[0].total==""?"0":jqZbd[0].total);
			
			//表格数据
			var datas = msg.records;
			var html = "";
			if(datas.length == 0){
				html += "<tr><td colspan='6' align='center'>没查询到符合条件的数据~</td></tr>";
			}else{
				for(var i = 0; i<datas.length; i++){
					html += "<tr>";
//					html += "<td><a style='color:blue' href='./playerDetailsInfo.php?gameId="+datas[i].gameId+"' title='查看玩家详情'>"+datas[i].nickName+"</a></td>";//昵称
					html += "<td>"+datas[i].nickName+"</td>";
					var amount = datas[i].amount;
					if(amount > 0){
						amount = "<font color='red'>"+amount+"</font>";
					}
					html += "<td style='font-weight:bold;'>"+amount+"</td>";//奖券变化
					html += "<td>"+datas[i].preAmount+"</td>";//变动前奖券
					html += "<td>"+datas[i].aftAmount+"</td>";//变动后奖券
					html += "<td>"+datas[i].logTime+"</td>";//时间
					html += "<td>"+datas[i].remark+"</td>";//描述
					html += "</tr>";
				}
			}
			$("#databody").html(html);
			
			//分页数据
			var pageInfos = msg.pageInfo;
			//总条数
			var allCount = pageInfos[0].count;
			$("#count").html(allCount);
			//总页数
			var allPage = Math.ceil(allCount/pageSize);
			if(allPage==0){
				allPage = 1;
			}
			//当前页码
			var now = pageInfos[0].page;
			
			$("#page").val(now);
			$("#nowPage").html(now);
			$("#allPage").html(allPage);
			$("#pageIpu").val("");
		}
	});
}